package com.blackhorse.order;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication//订单微服务 启动类
@EntityScan("com.blackhorse.order.entity")//Spring Data Jpa 实体类包扫描
public class OrderApplication {

    /**
     * SpringCloud对consul进行了进一步的封装，已经集成了ribbon
     * 注解@LoadBalanced 注解实现负载均衡
     * @return RestTemplate
     */
    //创建RestTemplate并交给IOC容器管理
    @Bean
    @LoadBalanced
    public RestTemplate createRestTemplate(){
        return new RestTemplate();
    }

    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }
}

